<?PHP
class Output
{
	private static $instance;
	private $data = Array('valid'=>1);
	
	private function __construct(){}
	public static function getInstance()
	{
		if(!isset(self::$instance))
		{
			$class = __CLASS__;
			self::$instance = new $class;
		}
		return self::$instance;
	}
	
	public function add($key, $value)
	{
		$this->data[$key] = $value;
	}
	
	public function has($key)
	{
		return(isset($this->data[$key]));
	}
	
	public function get($key)
	{
		if($this->has($key))
		{
			return $this->data[$key];
		}
		
		return false;
	}
	
	public function setTitle($title)
	{
		$this->data['title'] = $title;
	}
	
	public function invalidate($reason)
	{
		$this->data['valid'] = 0;
		$this->data['error'] = $reason;
	}
	
	public function send()
	{
		echo(json_encode($this->data));
	}
}
?>